@extends('public.dashboard_base')
@section('title', '添加邮箱认证')

@section('content')
    @php
        $user =auth('admin')->user();
    @endphp
    <div class="control_panel_content">
        <div class="navBreadcrumb">
            <ul>
                <li>账户管理</li>
                <li>邮箱认证</li>
                <li>添加邮箱认证</li>
            </ul>
        </div>
        <div class="panel">
            <div class="sub_nav_container">
                <ul class="clearfix">
                    <li><a href="/account/auth/email">邮箱认证</a></li>
                    <li class="active"><a href="/account/auth/email/add">添加邮箱认证</a></li>
                </ul>
            </div>
            <div class="panel_body">
                <form id="add_auth_form" action="/account/auth/email/add" method="post">
                    {{csrf_field()}}
                    <input type="text" name="email">&nbsp;
                    <input type="submit" id="add_auth" class="btn btn_primary" value="添加">
                </form>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script>
        $(function () {
            var link = $("#account-certification");
            link.parent().parent().parent().addClass("active");
            link.parent().addClass("active");

            $("#add_auth_form").validate({
                rules: {
                    email: {
                        required: true,
                        email: true,
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        success: function (data) {
                            if (data.msg === 'success') {
                                layer.msg('成功!', {icon: 1, time: 1000}, function () {
                                    window.location = '/account/auth/email';
                                })
                            } else {
                                layer.msg(data.data.error, {icon: 2, time: 1000,});
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('server error!', {icon: 2, time: 1000}, function () {
                            });
                        }
                    });
                }
            });
        });
    </script>
@endsection
